package com.youbug.mall.coupon_sms.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.youbug.common.vo.QueryVo;
import com.youbug.mall.coupon_sms.entity.SmsSeckillPromotion;
import com.youbug.mall.coupon_sms.service.ISmsSeckillPromotionService;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.springframework.web.bind.annotation.*;
import com.youbug.common.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 秒杀活动 前端控制器
 * </p>
 *
 * @author youbug
 * @since 2024-07-20
 */
@RestController
@RequestMapping("/smsSeckillPromotion")
public class SmsSeckillPromotionController {
@Autowired
private ISmsSeckillPromotionService smsSeckillPromotionService;

    @PostMapping("/getSmsSeckillPromotionPage")
    public R<IPage<SmsSeckillPromotion>> getSmsSeckillPromotionPage(@RequestBody QueryVo<SmsSeckillPromotion> queryVo){

        IPage<SmsSeckillPromotion> smsSeckillPromotions = smsSeckillPromotionService.getSmsSeckillPromotionPage(queryVo);

        return R.ok(smsSeckillPromotions);
    }

    @GetMapping("/getSmsSeckillPromotionById/{id}")
    public R<SmsSeckillPromotion> getSmsSeckillPromotionById(@PathVariable Long id){

        SmsSeckillPromotion smsSeckillPromotion = smsSeckillPromotionService.getById(id);

        return R.ok(smsSeckillPromotion);
    }

    @PostMapping("/add")
    public R<Boolean> add(@RequestBody SmsSeckillPromotion smsSeckillPromotion){

        boolean save = smsSeckillPromotionService.save(smsSeckillPromotion);

        return  R.ok(save);
    }

    @PostMapping("/update")
    public R<Boolean> update(@RequestBody SmsSeckillPromotion smsSeckillPromotion){

        boolean update = smsSeckillPromotionService.updateById(smsSeckillPromotion);

        return  R.ok(update);
    }

    @GetMapping("/delete/{id}")
    public R<Boolean> delete(@PathVariable Long id){

        boolean remove = smsSeckillPromotionService.removeById(id);

        return  R.ok(remove);
    }
}

